module touch_key_flow_led (
    input sys_clk,
    input sys_rst_n,
    input touch_key,
    output reg [3:0] led
);

reg [24:0] cnt = 25'b0;
reg state = 1'b0;

// 计数器，计时1s
always @(posedge sys_clk or negedge sys_rst_n) begin
    if(!sys_rst_n)
        cnt <= 25'd0;
    else if(cnt < 25'd25_000_000 - 25'd1)
        cnt <= cnt + 25'd1;
    else
        cnt <= 25'd0;
end

// 显示状�??
always @(posedge touch_key) begin
    state <= ~state;
end

// led显示控制
always @(posedge sys_clk or negedge sys_rst_n) begin
    if(!sys_rst_n)
        led <= 4'b0001;
    else if(state && (!led))
        led <= 4'b0001;
    else if((!state) && led)
        led <= 4'b0000;
    else if (cnt == 25'd0)
        led <= {led[2:0],led[3]};
    else
        led <= led;
end

endmodule